import { defineStore } from 'pinia'
import { getRoleInfo } from '@/api/base/Base'

export const useRoleStore = defineStore('role', {
  state() {
    return {
      roleInfo: {} as RoleInfo,
      roles: [] as RoleInfo[]
    }
  },
  getters: {},
  actions: {
    async InitRoleInfo() {
      const { data } = await getRoleInfo()
      this.roles = data
      this.roleInfo = data.find((ele) => ele.id == getRoleId()) ?? data[0]
      setRoleId(this.roleInfo.id)
    }
  }
})
